package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BizDataKjzz;
import com.ruoyi.system.service.IBizDataKjzzService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会计准则Controller
 * 
 * @author ruoyi
 * @date 2024-09-02
 */
@Controller
@RequestMapping("/system/kjzz")
public class BizDataKjzzController extends BaseController
{
    private String prefix = "system/kjzz";

    @Autowired
    private IBizDataKjzzService bizDataKjzzService;

    @RequiresPermissions("system:kjzz:view")
    @GetMapping()
    public String kjzz()
    {
        return prefix + "/kjzz";
    }

    /**
     * 查询会计准则列表
     */
    @RequiresPermissions("system:kjzz:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizDataKjzz bizDataKjzz)
    {
        startPage();
        List<BizDataKjzz> list = bizDataKjzzService.selectBizDataKjzzList(bizDataKjzz);
        return getDataTable(list);
    }

    /**
     * 导出会计准则列表
     */
    @RequiresPermissions("system:kjzz:export")
    @Log(title = "会计准则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizDataKjzz bizDataKjzz)
    {
        List<BizDataKjzz> list = bizDataKjzzService.selectBizDataKjzzList(bizDataKjzz);
        ExcelUtil<BizDataKjzz> util = new ExcelUtil<BizDataKjzz>(BizDataKjzz.class);
        return util.exportExcel(list, "会计准则数据");
    }

    /**
     * 新增会计准则
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会计准则
     */
    @RequiresPermissions("system:kjzz:add")
    @Log(title = "会计准则", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizDataKjzz bizDataKjzz)
    {
        return toAjax(bizDataKjzzService.insertBizDataKjzz(bizDataKjzz));
    }

    /**
     * 修改会计准则
     */
    @RequiresPermissions("system:kjzz:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BizDataKjzz bizDataKjzz = bizDataKjzzService.selectBizDataKjzzById(id);
        mmap.put("bizDataKjzz", bizDataKjzz);
        return prefix + "/edit";
    }

    /**
     * 修改保存会计准则
     */
    @RequiresPermissions("system:kjzz:edit")
    @Log(title = "会计准则", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizDataKjzz bizDataKjzz)
    {
        return toAjax(bizDataKjzzService.updateBizDataKjzz(bizDataKjzz));
    }

    /**
     * 删除会计准则
     */
    @RequiresPermissions("system:kjzz:remove")
    @Log(title = "会计准则", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizDataKjzzService.deleteBizDataKjzzByIds(ids));
    }
}
